package com.ah.shanxi_demo.controller.test;

import com.ah.shanxi_demo.param.result.OrderTypeRO;
import com.ah.shanxi_demo.param.result.SXResult;
import com.ah.shanxi_demo.service.IOrderService;
import com.ah.shanxi_demo.sync.param.result.SyncPolicyResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zt 2020/8/22
 */

@RestController
@Api(value = "陕西高速", description = "陕西高速-测试服务")
@RequestMapping(value = "/api/v1/shanxi/test/", produces = "application/json; charset=UTF-8")
public class APITestController {

    @Autowired
    private IOrderService orderService;


    @ApiOperation(value = "策略", notes = "策略查看")
    @RequestMapping(value = "policyTest", method = RequestMethod.POST)
    public SXResult<List<SyncPolicyResult>> policyTest(@RequestBody SyncPolicyResult syncPolicyResult) {
        List<SyncPolicyResult> list=new ArrayList<>();
        list.add(syncPolicyResult);

        System.out.println(JSON.toJSONString(syncPolicyResult));

        System.out.println(syncPolicyResult);

        SXResult sxResult = SXResult.instance(list);

        System.out.println(sxResult);

        System.out.println(JSONObject.toJSONString(sxResult));

        return SXResult.instance(list);
    }


    @ApiOperation(value = "工单类型查询", notes = "工单类型查询")
    @RequestMapping(value = "orderTest", method = RequestMethod.POST)
    public SXResult<List<OrderTypeRO>> orderTest() {

        List<OrderTypeRO> orderTypeROList = orderService.selectOrderType();

        return SXResult.instance(orderTypeROList);
    }

}
